<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>节目申请记录</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		 function cheackAll(obj){
	            var isCheck = $(obj).is(":checked");

	            $("#contentTable").find("input[type='checkbox']").each(function(){
	                $(this).prop("checked", isCheck);
	            });
	        }
	        function batchProcesst(flag){
	            var msg = "";
	            if (flag == 'pass') { msg = "<spring:message code='tips.allpass' />" }
	            else if (flag == 'reject') { msg = "<spring:message code='tips.alldismissal' />" }
	            else{ msg = "<spring:message code='tips.delall' />" }

	            confirmx(msg, function(){
	                var groupList = "";
	                $("#contentTable").find("input[type='checkbox']").each(function () {
	                    if ($(this).prop('checked')) {
	                        var egId = $(this).attr("id");
                            groupList = groupList + "'" + egId + "',";
	                    }
	                });
	                $.ajax({
	                    type: "POST",
	                    url: "${ctx}/source/eleSourceGroup/checkList",
	                    data: {groupList: groupList, flag: flag,type:'apply'},
	                    datatype: "json",
	                    success: function (data) {
	                        alertx(data.msg, function () {
	                            window.location.reload();
	                        });
	                    },
	                    error: function () {
	                        alertx("<spring:message code='tips.contactadmin' />");
	                        console.log(e);
	                    }
	                });
	            });
	        }
	    	function resubmit(){
				var groupList = "";
	            $("#contentTable").find("input[type='checkbox']").each(function () {
	                if ($(this).prop('checked')) {
	                    var egId = $(this).attr("id");
	                    groupList = groupList + "'" + egId + "',";
	                }
	            });
	            $.ajax({
	                type: "POST",
	                url: "${ctx}/source/eleSourceGroup/resubmit",
	                data: {groupList: groupList},
	                datatype: "json",
	                success: function (data) {
	                    alertx(data.msg, function () {
	                        window.location.reload();
	                    });
	                },
	                error: function (e) {
	                    alertx("<spring:message code='tips.contactadmin' />");
	                    console.log(e);
	                }
	            });
			}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/source/eleSourceGroup/applylist"><spring:message code='menu.program.Program_Package.Program_Apply'/></a></li>
	</ul>
	    <div class="control-group" style="margin-bottom:20px;/*background-color:#f5f5f5;*/" >
	  <input type="button" value="<spring:message code='Batch.deletion'/>" class="btn btn-default btn-lg" onclick="batchProcesst('delete');">
        	<input type="button" value="<spring:message code='common.resubmit'/>" class="btn btn-default btn-lg" onclick="resubmit();">
	<form:form id="searchForm" modelAttribute="eleSourceGroup" action="${ctx}/source/eleSourceGroup/applylist"
			   method="post" class="breadcrumb form-search" style="float:right;padding-bottom:0px;padding-top:0px;">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<input name="isFirst" type="hidden" value="${isFirst}">		
		<ul class="ul-form">

			<li><label><spring:message code='common.status'/>：</label>
                <form:select path="delFlag" htmlEscape="false"  class="input-medium">
                    <form:option value="5"><spring:message code="all"/></form:option>
                    <form:option value="0"><spring:message code="approved"/></form:option>
                    <form:option value="1"><spring:message code='common.delete'/></form:option>
                    <form:option value="2"><spring:message code='inapproval'/></form:option>
                    <form:option value="3"><spring:message code="rejected"/></form:option>
                </form:select>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="<spring:message code='common.Query'/>"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	</div>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
			   <th style="width:40px;text-align:center;"><input type="checkbox" onclick="cheackAll(this)"/></th>
				<th><spring:message code="package.name"/></th>
				<th><spring:message code='common.applicant'/></th>
				<th><spring:message code='common.applicant.time'/></th>
				
				<th><spring:message code="common.approver"/></th>
				<th><spring:message code="common.approver.time"/></th>

				<th><spring:message code="audit.state"/></th>
				<th><spring:message code="common.comment"/></th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="group">
			<tr>
			     <td style="text-align:center;"><input type="checkbox" id="${group.id}"/></td>	
				<td> ${group.name} </td>
				<td> ${group.createBy.name} </td>
				<td> <fmt:formatDate value="${group.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/> </td>
                <td> ${group.checkBy.name} </td>
                <td>  <fmt:formatDate value="${group.checkDate}" pattern="yyyy-MM-dd HH:mm:ss"/> </td>
				<td>
                    <c:if test="${group.delFlag == '0'}">
                        <spring:message code="approved"/>
                    </c:if>
                    <c:if test="${group.delFlag == '1'}">
                        <spring:message code='common.delete'/>
                    </c:if>
                    <c:if test="${group.delFlag == '2'}">
                        <spring:message code='inapproval'/>
                    </c:if>
                    <c:if test="${group.delFlag == '3'}">
                        <spring:message code="rejected"/>
                    </c:if>
                </td>
				<td> ${group.comment} </td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>